package com.jun;

import com.vdp.utils.JdbcUtils_DBCP;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class TestJdbc05 {
    public static void main(String[] args) {
        Connection conn=null;
        PreparedStatement ps=null;
        ResultSet rs =null;
        try {
            conn= JdbcUtils_DBCP.getConnection();
            String sql ="SELECT * FROM USERS WHERE id=?";
            ps=conn.prepareStatement(sql);
            ps.setInt(1,7);
            rs=ps.executeQuery();
            while(rs.next()){
                System.out.println(rs.getInt("id"));
                System.out.println(rs.getString("name"));
                System.out.println(rs.getString("password"));
                System.out.println(rs.getString("email"));
                System.out.println(rs.getDate("birthday"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        finally{
            JdbcUtils_DBCP.release(conn,ps,rs);
        }
    }
}

